﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for clsQtDeThi
/// </summary>
public class clsQtDeThi
{
    QLDETHIDataContext qldt = new QLDETHIDataContext();
	public clsQtDeThi()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public void ThemmoiQTDT(string maquytac, int soCH, int soKho, int soTB, int soDe)
    {
        QUYTACDE qtde = new QUYTACDE();
        qtde.MaQT = maquytac;
        qtde.SoCH = soCH;
        qtde.Kho = soKho;
        qtde.TB = soTB;
        qtde.De = soDe;
        qldt.QUYTACDEs.InsertOnSubmit(qtde);
        qldt.SubmitChanges();
 
    }
    public void XoaQTde(string maqtac)
    {
        var qt = from p in qldt.QUYTACDEs
                 where p.MaQT == maqtac
                 select p;
        qldt.QUYTACDEs.DeleteAllOnSubmit(qt);
        qldt.SubmitChanges();

 
    }
    public void SuaQTde(string maqtac,int soCH, int soKho, int soTB, int soDe)
    {
        var suaqt = (from p in qldt.QUYTACDEs
                     where p.MaQT == maqtac
                     select p).Single();
        suaqt.SoCH = soCH;
        suaqt.Kho = soKho;
        suaqt.TB = soTB;
        suaqt.De = soDe;
        qldt.SubmitChanges();
    }
    public int KTTrungMa(string maqt)
    {
        if (qldt.QUYTACDEs.Any(o_ql=>o_ql.MaQT==maqt))
        {
            return 1;
        }
        return 0;
                       
    }
}
